<?php

class tourney {
	// Class constructor
	public function __construct() {
		$this->db = database::getInstance();
	}
	
	// Check if a tourney exists
	public function tourneyExists($tid) {
		$result = $this->db->sqlResult("
			SELECT id 
			FROM tourneys
			WHERE tid=\"$tid\"
		");
		if(mysql_num_rows($result) > 0) {
			return true;
		} else {
			return false;
		}
	}
	
	// Create new tourney
	public function tourneyAdd($data) {
		$date = $data[8] . " " . $data[9];
		$this->db->sqlResult("
			INSERT INTO tourneys (tid, buyin, start)
			VALUES(\"$data[2]\", \"$data[3]\", \"$date\")
		");
	}
}

?>